package cn.ggcms.cms.dao.impl;

import java.util.List;

import cn.ggcms.cms.dao.MessagesDao;
import cn.ggcms.cms.utils.SimpleDao;
import cn.ggcms.cms.vo.Messages;

public class MessagesImpl extends SimpleDao<Messages> implements MessagesDao {


	public boolean doInsertMessages(Messages messages) {
		boolean flag = false;
		try {
			 super.save(messages);
			flag = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}
	public Messages findMessages(Messages messages) {
		return null;
		
	}
	public Messages finMessagesById(int id) {
		return (Messages) super.find(Messages.class,id);
	}
	public List<Messages> finMessagess() {

		return super.find(Messages.class);
	}
	public boolean doDeleteMessagesById(int id) {
		boolean flag = false;
		try {
			super.delete(Messages.class, id);
			flag = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
		
		
	}
	public boolean doUpdateMessages(Messages messages) {
		boolean flag = false;
		try {
			super.update(messages);
			flag = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return flag;
	}
	public List<Messages> findCMessagesByPage( int firstResult,
			int maxResults) {
	return	super.setFirstResult(firstResult).setMaxResults(maxResults).find(Messages.class);
	
	}
	public int getSize() {
		return super.getTotalPage(Messages.class);
	}
	
}
